<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * @author Truong Kim Phung
 * @copyright 2014
 */
class CI_Redirect {
	public function admin($strController, $strAction) {
		$arrControllerNoRedirect	= array('ajax','valid');
		if(in_array($strController, $arrControllerNoRedirect)) return;
		$arrActionNoRedirect 		= array (											
											'login',											
											'logout',
											'save',
											'saveedit',
											'act',
											'acto',
											'doupload',
                                            'changepw',
											'savecpw',
											'add',
											'edit',
											'delimg',
											'upload',
											'map'											
									);
		
		
		if (in_array($strAction, $arrActionNoRedirect)) return;
		/** Set Back URL **/
		$strBackURL = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		if (!in_array(strrchr($strBackURL, '.'), array('.gif','.png','.jpg','.xml','.ico','.htc','.swf','.css')) && !isset($_GET['error'])) {
			if (strrchr($strBackURL, '.') == '.htc') exit;
			$_SESSION[SESSION_BACKURL] = $strBackURL;
		}	
	}
	public function www($strController, $strAction) {
		/** Set Back URL **/
		$strBackURL = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		if (!in_array(strrchr($strBackURL, '.'), array('.gif','.png','.jpg','.xml','.ico','.htc','.swf','.css')) && !isset($_GET['error'])) {
			if (strrchr($strBackURL, '.') == '.htc') exit;
			$_SESSION[SESSION_BACKURL] = $strBackURL;
		}	
	}    
}
 
